import request from "../request";
import { type baseResponse } from '@/api/request'

export interface solid {
  id: number,
  areaId: number,
  name: string,
  areaName: string,
  createId: number,
  createTime: string,
  checkTime: string | null,
  lon: number,
  lat: number,
  filePath: string
}

export function getAllSolid () {
  return request.get<baseResponse<Array<solid>>>('/solidlist/findAll')
}

export function getByPage (params: { pageNum: number, pageSize: number, search: string }) {
  return request.get<baseResponse<{ pages: number, total: number, records: Array<solid> }>>('/solidlist/findPage', {
    params
  })
}

export function savaSolid (data: { name: string, createId: number, areaId: string, areaName: string, lon: number, lat: number }) {
  return request.post<baseResponse<any>>("/solidlist/save", data)
}

export function deleteSolid (id: number) {
  return request.delete<baseResponse<any>>("/solidlist/delete", {
    params: {
      id
    }
  })
}

export function getByArea (areaId: number = 1) {
  return request.get<baseResponse<Array<solid>>>('/solidlist/findByArea', {
    params: {
      areaId: areaId
    }
  })
}

export function getAreaCount () {
  return request.get<baseResponse<Array<{ name: string, count: number }>>>('/solidlist/findAreaCount').then(res => res.data)
}